﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using Hands.UriRewrite;
using Test.Event.BusTest;
using Hands.EventBus;
//using UriOverwrite.OverwriteException;
//using UriOverwrite;

namespace Test
{
    class Program
    {
        //const string testPath = "/house/css/fdasdf21312321";

        //private delegate IRewrite QueryEventHandler(string path);
        //private delegate string RewriteEventHandler(string path);

        //static Stopwatch watch = new Stopwatch();

        static void Main(string[] args)
        {

            //{
            //    watch.Start();

            //    QueryEventHandler queryHandler = new QueryEventHandler(new UriRootPathQuery().find);
            //    IRewrite rewrite = queryHandler.Invoke(testPath);
            //    RewriteEventHandler rewriteHandler = new RewriteEventHandler(rewrite.rewrite);
            //    string path = rewriteHandler.Invoke(testPath);//, new AsyncCallback(callbackRewrite), rewriteHandler);


            //    watch.Stop();

            //    Console.WriteLine("httpModule:" + watch.Elapsed);

            //    watch.Reset();

            //    Console.Read();

            //Stopwatch watch = new Stopwatch();

            //watch.Start();
            Factory factory = new EventCenterFactory();
            IPublish publish = factory.getPublishInstance();

            Handler1.init();

            TestEvent message = new TestEvent();
            publish.publish(message);

            //watch.Stop();

            //string temp = watch.Elapsed.ToString(); ;

            // Console.Read();

        }

        //private static void callbackQuery(IAsyncResult result)
        //{
        //    IRewrite rewrite = (result.AsyncState as QueryEventHandler).EndInvoke(result);
        //    if (rewrite != null)
        //    {
        //        watch.Start();
        //        RewriteEventHandler rewriteHandler = new RewriteEventHandler(rewrite.rewrite);
        //        rewriteHandler.BeginInvoke(testPath, new AsyncCallback(callbackRewrite), rewriteHandler);

        //        watch.Stop();
        //    }
        //}
    }
}
